// src/types/types.ts

// user login input data structure
export interface LoginFormData {
  email: string;
  password: string;
}

// user profile data structure
export interface UserData {
  userId: number;
  email: string;
  firstName: string;
  lastName: string;
  role: string;
  permissions: number[];
}

// user login response data structure
export interface LoginResponseData {
  token: string;
  user: UserData;
}

// user register input data structure
export interface CreateAccountFormData {
  firstName: string;
  lastName: string;
  email: string;
  password: string;
}

// user regitster send to server data structure
export interface CreateAccountPayload {
  first_name: string;
  last_name: string;
  email: string;
  password: string;
}

// user register response data structure
export interface CreateAccountResponseData {
  token: string;
  user: UserData;
}

// user profile response data structure (matches backend UserInfoResponse)
export interface UserProfileResponse {
  first_name: string;
  last_name: string;
  email: string;
  role_name: string;
  permission_ids: number[];
}

// user display info data structure
export interface DisplayUserInfo {
  userId: number;
  firstName: string;
  lastName: string;
  email: string;
}

// user editable info data structure
export interface EditableUser extends DisplayUserInfo {
  permissions: number[];
}

// user list props data structure
export interface UserListProps {
  users: EditableUser[];
  onClose: () => void;
}

// edit permission props data structure
export interface EditPermissionProps {
  user: EditableUser;
  onClose: () => void;
  onSuccess: (updatedUser: EditableUser) => void;
}

// edit permission confirm props data structure
export interface EditPermissionConfirmProps {
  email: string;
  newPermissions: number[];
  onCancel: () => void;
  onSuccess: () => void;
}

// update permissions response data structure
export interface UpdatePermissionsResponse {
  code: number;
  message: string;
  data: {
    email: string;
    updated_permissions: number[];
  };
}

// update profile request data structure
export interface UpdateProfileRequest {
  first_name?: string;
  last_name?: string;
  email?: string;
}

// settings props data structure
export interface SettingsProps {
  firstName: string;
  lastName: string;
  email: string;
  onClose: () => void;
  onUpdateUser?: (data: {
    first_name?: string;
    last_name?: string;
    email?: string;
  }) => void;
}

// change password request data structure
export interface ChangePasswordRequest {
  old_password: string;
  new_password: string;
}

// logout props data structure
export interface LogoutProps {
  onConfirm: () => void;
  onCancel: () => void;
}

// sponsor record params data structure
export interface SponsorRecordParams {
  year_from: number;
  year_to: number;
  current?: boolean;
  program_id?: number;
  program_code?: string | string[];
  faculty?: string | string[];
  coop_program?: string | string[];
  page?: number;
  page_size?: number;
}

// sponsor record data structure
export interface SponsorRecord {
  sponsor_id: number;
  company_code: string;
  company_name: string;
  contacts: unknown[];
  umbrella_code: string | null;
  umbrella_name: string | null;
  program_id: number;
  program_code: string;
  scholarship_years: string;
  latest_year: number;
  status: string;
  program_year: number;
  program_length: number;
  program_value: number;
  faculty: string;
  coop_program: string;
  position: number;
  total_amount_per_position: number;
  sponsorship_cost: number;
  logo: string | null;
  logo_last_updated: string | null;
}

// sponsor records response data structure
export interface SponsorRecordsResponse {
  meta: {
    total: number;
    page: number;
    page_size: number;
  };
  items: SponsorRecord[];
}

// scholar record params data structure
export interface ScholarRecordParams {
  skip?: number;
  limit?: number;
}

// scholar record data structure
export interface ScholarRecord {
  program: string | null;
  year: number | null;
  student_number: string | null;
  first_name: string | null;
  preferred_name: string | null;
  last_name: string | null;
  default_email: string | null;
  alternate_email: string | null;
  university_status: string | null;
  date_of_birth: string | null;
  gender: string | null;
  school_code: string | null;
  school_name: string | null;
  gateway_school: boolean | null;
  indigenous_student: string | null;
  start_date: string | null;
  end_date: string | null;
  scholar_type: string | null;
  dietary_preference: string | null;
  dietary_allergies: string | null;
  dietary_religious: string | null;
  medical_allergies: string | null;
  ite_number: number | null;
  sponsor_name: string | null;
  department: string | null;
  supervisors: string | null;
  ite_start: string | null;
  ite_end: string | null;
  ite_details_input_date: string | null;
  ite_input_in_time: boolean | null;
  latest_start_date: string | null;
  expected_finish_date: string | null;
  start_date_met: boolean | null;
  end_date_met: boolean | null;
  it_change_approved: boolean | null;
  pd_agreement_submission_date: string | null;
  // pd_submitted_on_time: boolean | null;
  placement_mid_point: string | null;
  mpc_call_date: string | null;
  mpc_call_on_time: string | null;
  mpc_document_due_date: string | null;
  mpc_submitted_date: string | null;
  mpc_submitted_on_time: boolean | null;
  end_of_it_presentation_date: string | null;
  end_of_it_input_date: string | null;
  it_presentation_completed_ontime: string | null;
  unsw_attendee_on_presentation: boolean | null;  
  sponsor_evaluation_sent_to_sponsor_date: string | null;
  sent_before_end_of_placement: boolean | null;
  sponsor_completed_date: string | null;
  scholar_comment: string | null;
  sponsor_evaluation_completed_on_time: boolean | null;
  placement_completed_date: string | null;
  placement_grade: string | null;
  placement_performance: string | null;
  grade_updated: string | null;
  grade_updated_date: string | null;
}

// scholar records response data structure
export interface ScholarRecordsResponse {
  total: number;
  scholars: ScholarRecord[];
}